package reflectCus;

import java.lang.reflect.Method;

//反射---调用有参的方法
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception{
      Method method=  Person.class.getDeclaredMethod("eat");
        method.setAccessible(true);
        method.invoke( Person.class.newInstance());
        method.invoke( Person.class.newInstance());
        method.invoke( Person.class.newInstance());

        Class c=Class.forName("reflectCus.Person");
        Object object=c.newInstance();

        Method m=c.getMethod("play",String.class,String.class);
        m.invoke(object,"斗地主","王者");
        //method.setAccessible(false);
        method.invoke( Person.class.newInstance());
    }
}
